import { request } from '@pkg/request/src';

export enum Api {
  page = '/front/user/page',
  get = '/front/user/get',
  update = '/front/user/update',
  save = '/front/user/saveUser',
  remove = '/front/user/remove',
  setUserStatus = '/front/user/setStatus',
  unBindOpenId = '/userExt/unBindOpenId',
  resetPwd = '/userExt/resetPwd',
  changeMobile = '/userExt/changeMobile',
  companyList = '/company/list',
  importNewUserExcel = '/userExt/importNewUserExcel',
}

export const getUserInfo = (params) =>
  request.get(
    {
      url: Api.get,
      params: params,
    },
    { errorMessageMode: 'message', successMessageMode: 'none' },
  );

export const setUserStatus = (userId: number) =>
  request.post({
    url: Api.setUserStatus,
    params: { userId: userId },
  });

export const unBindOpenId = (userId: number) =>
  request.post({
    url: Api.unBindOpenId,
    params: { userId: userId },
  });
export const resetPwd = (userId: number) =>
  request.post({
    url: Api.resetPwd,
    params: { userId: userId },
  });

export const userUpdate = (params) =>
  request.post(
    {
      url: Api.update,
      params: params,
    },
    { errorMessageMode: 'message' },
  );

export const changeMobile = (params) =>
  request.post(
    {
      url: Api.changeMobile,
      params: params,
    },
    { errorMessageMode: 'message' },
  );
export const companyList = (params) =>
  request.get(
    { url: Api.companyList, params },
    {
      errorMessageMode: 'none',
      successMessageMode: 'none',
    },
  );
